﻿using EmailClient.Model;
using EmailClient.View;
using EmailClient.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace EmailClient.UserControls
{
    /// <summary>
    /// Interaction logic for AccountsList.xaml
    /// </summary>
    public partial class AccountsList : UserControl
    {
        public AccountsList()
        {
            InitializeComponent();
            FillList();
        }

        public async Task<string> FillList()
        {
            dgAccounts.DataContext = await AccountViewModel.GetList();
            return "success";
        }

        public event RoutedEventHandler AddAccountPress;
        private void AddAccount_Click(object sender, RoutedEventArgs e)
        {
            if (AddAccountPress != null) AddAccountPress(sender, e);
        }

        public event RoutedEventHandler EditAccountPress;
        private void EditAccount_Click(object sender, RoutedEventArgs e)
        {
            if (EditAccountPress != null) EditAccountPress(sender, e);
        }

        public event RoutedEventHandler DelAccountPress;
        private void DelAccount_Click(object sender, RoutedEventArgs e)
        {
            if (DelAccountPress != null) DelAccountPress(sender, e);
        }

        public event RoutedEventHandler Accounts_MouseDoubleClick;
        private void dgAccounts_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (Accounts_MouseDoubleClick != null) Accounts_MouseDoubleClick(sender, e);
        }
    }
}
